package com.bjsxt.buyaction.conf;

import com.bjsxt.publisher.LivegoodsMessagePublisher;
import com.bjsxt.redis.conf.RedisCacheConfiguration;
import com.netflix.discovery.converters.Auto;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @ClassName : BuyactionConfiguration
 * @Description :
 * @Author : ZWZ
 * @Date: 2021/8/27 15:08
 */
@Configuration
public class BuyActionConfiguration extends RedisCacheConfiguration {

    @Bean
    @Override
    protected RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        return super.redisTemplate(redisConnectionFactory);
    }

    /**
     * 创建 livegoodsMessagePublisher 对象， 并放入到的  Spring IOC 容器中
     *
     * @param amqpTemplate
     * @return
     */
    @Bean
    public LivegoodsMessagePublisher livegoodsMessagePublisher(AmqpTemplate amqpTemplate) {
        LivegoodsMessagePublisher livegoodsMessagePublisher = new LivegoodsMessagePublisher();
        livegoodsMessagePublisher.setAmqpTemplate(amqpTemplate);
        return livegoodsMessagePublisher;
    }

}
